<?php
if (!defined('__TYPECHO_ROOT_DIR__')) exit;
/**
 * 你写下的每个字，都值得被温柔对待。
 * 
 * 你可以在<a href="https://amrx.me">静语·偶尔有风</a>获得更多关于此皮肤的信息
 * 
 * @package Restext Theme 
 * @author 简 / Jane
 * @version 2.6.0
 * @link https://amrx.me
 */
$this->need('header.php');
?>
        
        <?php if ($this->options->index_display_type == 'image' && !empty($this->options->Index_images)): ?>
            <section class="img-container home-header-bg-full">
                <header class="home-header-img">
                    <img data-src="<?php $this->options->Index_images(); ?>">
                </header>
                <div class="waves-box">
                    <svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"></path></defs><g class="parallax"><use xlink:href="#gentle-wave" x="48" y="0"></use><use xlink:href="#gentle-wave" x="48" y="3"></use><use xlink:href="#gentle-wave" x="48" y="5"></use><use xlink:href="#gentle-wave" x="48" y="7"></use></g>
                    </svg>
                </div>
            </section>
        <?php elseif($this->options->Index_video) : ?>
            <!-- 视频 -->
            <section class="video-container home-header-bg-full">
                <div class="video-bg">
                    <video id="myVideo" autoplay muted playsinline loop style="object-fit:cover">
                        <source src="<?php $this->options->Index_video(); ?>" type="video/mp4">
                    </video>
                </div>
                <div class="waves-box">
                    <svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"></path></defs><g class="parallax"><use xlink:href="#gentle-wave" x="48" y="0"></use><use xlink:href="#gentle-wave" x="48" y="3"></use><use xlink:href="#gentle-wave" x="48" y="5"></use><use xlink:href="#gentle-wave" x="48" y="7"></use></g>
                    </svg>
                </div>
            </section>
        <?php elseif($this->options->Index_banner) : ?>
            <!-- 幻灯片 -->
            <section class="single-list home-header-bg-full">
                <?php
                    $slides = [];
                    $slides_text = $this->options->Index_banner; // 假设 Index_banner 存储了幻灯片数据
                    if ($slides_text) {
                        $slides_arr = explode("\r\n", $slides_text);
                        if (count($slides_arr) > 0) {
                            for ($i = 0; $i < count($slides_arr); $i++) {
                                $slide_data = explode("||", $slides_arr[$i]);
                                $title = trim($slide_data[0]); // 幻灯片标题
                                $image_url = trim($slide_data[1]); // 幻灯片图片URL
                                $link_url = trim($slide_data[2]); // 幻灯片链接URL
                                $slides[] = array(
                                    "title" => $title,
                                    "image_url" => $image_url,
                                    "link_url" => $link_url
                                );
                            }
                        }
                    }
                ?>
                <?php if (!empty($slides)): ?>
                
                    <?php foreach ($slides as $slide): ?>
                        <div class="single-item">
                            <div class="single-banlist">
                                <a href="<?php echo $slide['link_url']; ?>" target="_blank" rel="noopener noreferrer" >
                                    <img data-src="<?php echo $slide['image_url']; ?>" width="100%" alt="<?php echo $slide['title']; ?>">
                                    <h1 class="hero-header-title">
                                        <?php echo $slide['title']; ?>
                                    </h1>
                                    <span class="single_blur"></span>
                                </a>
                            </div>
                            
                            <div class="waves-box">
                                <svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto">
                                    <defs>
                                        <path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z"></path>
                                    </defs>
                                    <g class="parallax">
                                        <use xlink:href="#gentle-wave" x="48" y="0"></use>
                                        <use xlink:href="#gentle-wave" x="48" y="3"></use>
                                        <use xlink:href="#gentle-wave" x="48" y="5"></use>
                                        <use xlink:href="#gentle-wave" x="48" y="7"></use>
                                    </g>
                                </svg>
                            </div>
                        </div>
                        
                    <?php endforeach; ?>
                    
                <?php endif; ?>
                
            </section>
        <?php endif; ?>
        
        <main class="container">
            <section class="category-list">
                <div class="new-container">
                    <header class="to-header">
                        <h2 class="category-title" id="new">
                            最新
    			        </h2>
                    </header>
                    <div class="to-list">
                        <?php if ($this->have()): ?>
                        <?php while($this->next()): ?>
                        <article class="up-card">
                            <a class="new-excerpt line-clamp" href="<?php $this->permalink() ?>" id="<?php echo _getAbstract($this,300); ?>">
                                <?php $this->title() ?>
                            </a>
                        </article>
                        <?php endwhile; ?>
                        <?php else: ?>暂无文章<?php endif; ?>
                    </div>
                </div>
                <?php $this->need('layout/index-category.php');?>
            </section>
        </main>
    
    <?php $this->need('layout/footer.php');?>
    <?php $this->need('footer.php');?>
        
